﻿@using Covenant.Models.Grunts
@model IEnumerable<Grunt>

<div class="table-responsive">
    <table id="grunt-table" class="table table-hover">
        <thead>
            <tr>
                <th>@Html.DisplayNameFor(model => model.Name)</th>
                <th>@Html.DisplayNameFor(model => model.ImplantTemplate)</th>
                <th>@Html.DisplayNameFor(model => model.Hostname)</th>
                <th>@Html.DisplayNameFor(model => model.UserName)</th>
                <th>@Html.DisplayNameFor(model => model.Status)</th>
                <th>@Html.DisplayNameFor(model => model.LastCheckIn)</th>
                <th>@Html.DisplayNameFor(model => model.Integrity)</th>
                <th>@Html.DisplayNameFor(model => model.OperatingSystem)</th>
                <th>@Html.DisplayNameFor(model => model.Process)</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                @if (item.Status != GruntStatus.Uninitialized && item.Status != GruntStatus.Hidden)
                {
                    @if (item.Status == GruntStatus.Active)
                    {
                        <tr>
                            <td>
                                <a asp-controller="Grunt" asp-action="Interact" asp-route-id="@item.Id">
                                    @Html.DisplayFor(modelItem => item.Name)
                                </a>
                            </td>
                            <td>@Html.DisplayFor(modelItem => item.ImplantTemplate.Name)</td>
                            <td>@Html.DisplayFor(modelItem => item.Hostname)</td>
                            <td>@Html.DisplayFor(modelItem => item.UserName)</td>
                            <td>@Html.DisplayFor(modelItem => item.Status)</td>
                            <td>@Html.DisplayFor(modelItem => item.LastCheckIn)</td>
                            <td>@Html.DisplayFor(modelItem => item.Integrity)</td>
                            <td>@Html.DisplayFor(modelItem => item.OperatingSystem)</td>
                            <td>@Html.DisplayFor(modelItem => item.Process)</td>
                        </tr>
                    }
                    else
                    {
                        <tr style="opacity: 0.3;">
                            <td>
                                <a asp-controller="Grunt" asp-action="Interact" asp-route-id="@item.Id">
                                    @Html.DisplayFor(modelItem => item.Name)
                                </a>
                            </td>
                            <td>@Html.DisplayFor(modelItem => item.ImplantTemplate.Name)</td>
                            <td>@Html.DisplayFor(modelItem => item.Hostname)</td>
                            <td>@Html.DisplayFor(modelItem => item.UserName)</td>
                            <td>@Html.DisplayFor(modelItem => item.Status)</td>
                            <td>@Html.DisplayFor(modelItem => item.LastCheckIn)</td>
                            <td>@Html.DisplayFor(modelItem => item.Integrity)</td>
                            <td>@Html.DisplayFor(modelItem => item.OperatingSystem)</td>
                            <td>@Html.DisplayFor(modelItem => item.Process)</td>
                        </tr>
                    }
                }
            }
        </tbody>
    </table>
</div>